home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / utils / messages.SH < prev    next >
Encoding:
Text File  |  1992-10-17  |  1.3 KB  |  62 lines

  1. case $CONFIG in
  2. '')
  3.     if test ! -f config.sh; then
  4.     ln ../config.sh . || \
  5.     ln ../../config.sh . || \
  6.     ln ../../../config.sh . || \
  7.     (echo "Can't find config.sh."; exit 1)
  8.     fi
  9.     . ./config.sh
  10.     ;;
  11. esac
  12. case "$0" in
  13. */*) cd `expr X$0 : 'X\(.*\)/'` ;;
  14. esac
  15.  
  16. echo "Extracting utils/messages (with variable substitutions)"
  17. echo $startsh > messages
  18. cat >>messages <<'!NO!SUBS!'
  19. # messages: part of the Elm mail system
  20. # @(#)$Id: messages.SH,v 5.2 1992/10/17 22:38:58 syd Exp $
  21. #        Copyright (c) 1988-1992 USENET Community Trust
  22. #         Copyright (c) 1986,1987 Dave Taylor
  23.  
  24. if [ "$2" != "" ]; then
  25.   echo Usage: messages \{folder-name\} 1>&2
  26.   exit 1
  27. fi
  28.  
  29. if [ "$1" = "" ]; then
  30. !NO!SUBS!
  31. echo "  fname=\${MAIL-$maildir/\$LOGNAME}" >> messages
  32. cat >>messages <<'!NO!SUBS!'
  33.   optional="in your incoming mailbox"
  34. else
  35.   optional="in folder $1"
  36.   first=`expr "$1" : "\(.\).*"`
  37.   if [ "$first" = "=" ]; then
  38.     last=`expr "$1" : ".\(.*\)"`
  39.     fname="`grep maildir $HOME/.elm/elmrc | awk -F= '{print $2}'| tr -d ' '`/$last"
  40.   else
  41.     fname=$1
  42.   fi
  43. fi
  44.  
  45. if [ -f "$fname" ]; then
  46.   mcount=`egrep -c "^From " $fname`
  47. else
  48.   echo "Folder $1 does not exist."
  49.   exit 0
  50. fi
  51.  
  52. if [ "$mcount" -eq 1 ]; then
  53.   echo There is 1 message $optional.
  54. elif [ "$mcount" -eq 0 ]; then
  55.   echo There are no messages $optional.
  56. else
  57.   echo There are $mcount messages $optional.
  58. fi
  59.  
  60. exit $mcount
  61. !NO!SUBS!
  62.